package com.cj.models;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import java.util.Date;

@Data
@TableName(value = "book_reviews")
public class BookReviews {
    @TableId(value = "r_id",type = IdType.AUTO)
    @JsonProperty(value = "rid")
    private int rId;

    @NotEmpty
    @Length(min = 2,max = 200)
    @TableField(value = "r_text")
    @JsonProperty(value = "text")
    private String rText;

    @Min(value = 1)
    @TableField(value = "user_id")
    @JsonProperty(value = "uid")
    private int userId; //用户ID

    @TableField(value = "book_id")
    @JsonProperty(value = "bookid")
    private int bookId; //图书ID

    @Min(value = 0)
    @Max(value = 5)
    @TableField(value = "r_score")
    @JsonProperty(value = "score")
    private int rScore;

    @JsonFormat(pattern = "yyyy-MM-dd")
    @JsonProperty(value = "date")
    @TableField(value = "r_date")
    private Date rDate;
}
